<?php

namespace app\queue\rabbitmq;

use app\model\Banner;
use Roiwk\Rabbitmq\AbstractConsumer;
use Roiwk\Rabbitmq\Producer;
use Bunny\Channel;
use Bunny\Message;
use Bunny\AbstractClient;
use support\Redis;

class Hello extends AbstractConsumer
{
    protected bool $async = true;

    protected string $queue = 'hello';

    protected array $consume = [
        'noAck' => true,
    ];

    /**
     * 消费者(consumer)
     * 生产者调用
     * Producer::connect(config('process.hello-rabbitmq.constructor.rabbitmqConfig'), config('process.hello-rabbitmq.constructor.logger'))->publishSync('Hello World!', '', '', 'hello');
     */
    public function consume(Message $message, Channel $channel, AbstractClient $client)
    {
        //Redis::set('ReceivedOwen'.time(), $message->content);
        //Banner::where('id', 1)->update(['title' => $message->content, 'create_time' => time()]);
        echo " [x] Received ", $message->content, "\n";
    }
}